package com.example.onlinemusic.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/*
 * 要确保后端服务器已经正确配置了静态资源映射，从而让前端能够访问 /uploads/avatars/ 目录下的文件。
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/uploads/avatars/**")
                .addResourceLocations("file:A:\\code\\learn-java-ee\\music-player\\uploads\\avatars\\");
    }
}